package View

import ControllerView.ControllerView
import com.trolltech.qt.gui._

/**
 * Created by IntelliJ IDEA.
 * User: romaincherix
 * Date: 02.05.11
 * Time: 19:11
 * To change this template use File | Settings | File Templates.
 */

class KeyInfoView(controller:ControllerView, parent:QWidget)  extends View(controller, parent) {

  protected var buttonKeyPath = new QPushButton(container)


  protected var labelPath = new QLabel(container)       //contains the key path
  protected var labelAlias = new QLabel (container)     //contains key name
  protected var labelStorePass = new QLabel(container)  //contains store password
  protected var labelAliasPass = new QLabel(container)  //contains alias password


  var lineEditPath = new QLineEdit(container)
  var lineEditAlias = new QLineEdit (container)
  var lineEditStorePass = new QLineEdit(container)
  var lineEditAliasPass = new QLineEdit(container)


  protected var gridLayout = new QGridLayout(container)


  // init View
  this.initView


  /**
   * Initialize the view
   */
  private def initView {


    // size of the view
    this.setGeometry(TOOLS_VIEW_SIZE)


    // set the text
    labelPath.setText("Key path")
    labelAlias.setText("Key alias")
    labelStorePass.setText("Store password")
    labelAliasPass.setText("Alias password")


    // edit the button browse
    buttonKeyPath.setText("Browse")
    buttonKeyPath.setObjectName(CSS_BROWSE_BUTTON)
    buttonKeyPath.setFixedSize(SIZE_BUTTON_BROWSE)

    // connection
    buttonKeyPath.clicked.connect(controller, "browseKeyPath()")


    // create the grid layout
    gridLayout.addWidget(labelPath, 0, 0)
    gridLayout.addWidget(lineEditPath, 0, 1)
    gridLayout.addWidget(buttonKeyPath, 0 , 2)

    gridLayout.addWidget(labelAlias, 1, 0)
    gridLayout.addWidget(lineEditAlias, 1, 1, 1, 2)

    gridLayout.addWidget(labelStorePass, 2, 0)
    gridLayout.addWidget(lineEditStorePass, 2, 1, 1, 2)

    gridLayout.addWidget(labelAliasPass, 3, 0)
    gridLayout.addWidget(lineEditAliasPass, 3, 1, 1, 2)
  }

  /**
   * Clear all line edit
   */
  def clearLineEdit{

    lineEditAlias.clear
    lineEditAliasPass.clear
    lineEditStorePass.clear
    lineEditPath.clear

  }

}